import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.dysmsapi.model.v20170525.QuerySendDetailsRequest;
import com.aliyuncs.dysmsapi.model.v20170525.QuerySendDetailsResponse;
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest;
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
import com.aliyuncs.http.MethodType;
import com.aliyuncs.profile.DefaultProfile;
import com.aliyuncs.profile.IClientProfile;
import com.google.common.collect.ImmutableMap;
import com.teamclub.util.libs.Json;

public class A {
    public static IAcsClient getAcsClient() throws Exception{
        System.setProperty("sun.net.client.defaultConnectTimeout", "10000");
        System.setProperty("sun.net.client.defaultReadTimeout", "10000");

        final String product = "Dysmsapi";
        final String domain = "dysmsapi.aliyuncs.com";
        final String accessKeyId = "LTAI0QanHr1uCsNG";
        final String accessKeySecret = "fFYhhBsaudNH7V7iZ0sg9G5Pea6ntO";

        IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", accessKeyId, accessKeySecret);
        DefaultProfile.addEndpoint("cn-hangzhou", "cn-hangzhou", product, domain);
        IAcsClient acsClient = new DefaultAcsClient(profile);
        return acsClient;
    }

    public static void main(String[] args) throws Exception{
        IAcsClient acsClient = getAcsClient();
        SendSmsRequest request = new SendSmsRequest();
        request.setMethod(MethodType.POST);
        request.setPhoneNumbers("15919492724"); //必填:短信签名-可在短信控制台中找到
        request.setSignName("winder科技"); //必填:短信签名-可在短信控制台中找到
        request.setTemplateCode("SMS_112475212"); //必填:短信模板-可在短信控制台中找到
        request.setTemplateParam(Json.stringify(Json.toJson(ImmutableMap.of("code", 1234))));
        SendSmsResponse sendSmsResponse = acsClient.getAcsResponse(request);
        System.out.println(sendSmsResponse);
        if(sendSmsResponse.getCode() != null && sendSmsResponse.getCode().equals("OK")) {

        }
    }
}
